﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RoleList.aspx.cs" Inherits="TaoSH.View.RoleList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>角色列表</title>
    <link rel="stylesheet" href="../../CSS/bootstrap3.2/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../../CSS/Admin/Admin.css" />
    <link rel="stylesheet" type="text/css" href="../../CSS/Admin/Role.css" />
    <link rel="stylesheet" type="text/css" href="../../JqueryPlug/smartMenu/css/smartMenu.css" />
    <script type="text/javascript" src="../../Scripts/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../../JqueryPlug/smartMenu/js/jqueryMenu.js"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            //创建新角色
            $("#divaddrole").click(function (e) {
                var obj = $("#MangerRole").html();
                MyDialog.btview('添加角色', obj, '确认添加', function () {
                    var rolename = $("#tbRoleName").val();
                    var roledec = $("#tbRoleDec").val();
                    var issys = $("#ckIsSys").attr("checked") ? "Y" : "N";
                    var isuse = $("#ckIsUse").attr("checked") ? "Y" : "N";
                    $.ajax({
                        type: "GET",
                        url: "AdminHandle.ashx",
                        dataType: "html",
                        data: { "Action": "addRole", "rolename": rolename, "roledec": roledec, "issys": issys, "isuse": isuse },
                        success: function (msg) {
                            MyDialog.tips("添加成功", function () {
                                location.reload();
                            })
                        }
                    });
                });
            });
            //按字母查找
            $("#divsort span").click(function (e) {
                var text = $(this).text();
                $("#divrole .topic-item").hide();
                if (text === "ALL") {
                    $("#divrole .topic-item").show();
                }
                else if (text === "系统角色") {
                    $("#divrole  div[issys='Y']").show();
                }
                else if (text === "不可用角色") {
                    $("#divrole  div[isuse='N']").show();
                }
                else {
                    $("#divrole  div[serzm='" + text + "']").show();
                }
                $("#divsort span").css({ "color": "#4987C9" });
                $(this).css({ "color": "#ff7e00" });

            });

            //角色单击事件
            var bodyMenuData = [
                [{
                    text: "删除角色.",
                    func: function () {
                        var rolecode = $(this).attr('rolecode');
                        var role = $(this);
                        MyDialog.confirm('你确定要删除该角色吗', function () {
                            $.ajax({
                                type: "GET",
                                url: "AdminHandle.ashx",
                                dataType: "html",
                                data: { "Action": "delRole", "delCode": rolecode },
                                success: function (msg) {
                                    MyDialog.tips("删除成功", function () {
                                        location.reload();
                                    })
                                }
                            });
                        });

                    }
                }, {
                    text: "修改角色.",
                    func: function () {
                        var obj = $("#MangerRole").html();
                        var rolecode = $(this).attr('rolecode');
                        MyDialog.btview('修改角色', obj, '确认修改', function () {
                            var rolename = $("#tbRoleName").val();
                            var roledec = $("#tbRoleDec").val();
                            var issys = $("#ckIsSys").attr("checked") ? "Y" : "N";
                            var isuse = $("#ckIsUse").attr("checked") ? "Y" : "N";
                            $.ajax({
                                type: "GET",
                                url: "AdminHandle.ashx",
                                dataType: "html",
                                data: { "Action": "updateRole", "rolecode": rolecode, "rolename": rolename, "roledec": roledec, "issys": issys, "isuse": isuse },
                                success: function (msg) {
                                    MyDialog.tips("修改成功", function () {
                                        location.reload();
                                    })
                                }
                            });
                        });
                        //初始化修改窗口
                        $("#tbRoleName").val($(this).attr('rolename'));
                        $("#tbRoleDec").val($(this).attr('roledec'));
                        $("#ckIsSys").attr("checked", $(this).attr('issys') == "Y" ? true : false);
                        $("#ckIsUse").attr("checked", $(this).attr('isuse') == "Y" ? true : false);
                    }
                }],
                [{
                    text: "管理角色人员.",
                    func: function () {
                        var rolecode = $(this).attr('rolecode');
                        var pageurl = 'AassignUser.aspx?RoleCode=' + rolecode;
                        MyDialog.viewform(pageurl, '管理角色人员', 450, 500);
                    }
                }, {
                    text: "管理角色权限.",
                    func: function () {
                        var rolecode = $(this).attr('rolecode');
                        var pageurl = 'AassignMenu.aspx?RoleCode=' + rolecode;
                        MyDialog.viewform(pageurl, '管理角色权限', 450, 500);
                    }
                }]
            ];
            $("#divrole .topic-item").smartMenu(bodyMenuData, {
                name: "menurole"
            });
            //角色单击事件

        });</script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="topic-item" style="float: none; margin-bottom: 20px;" id="divaddrole">
            <div class="topic-img">
                <img src="../../images/ic_popup_new.png" style="width: 64px; height: 64px;">
            </div>
            <div class="topic-title">
                <span style="color: red;">创建新角色</span>
            </div>
        </div>
        <hr style="width: 97%" />
        <div style="width: 97%; padding-left: 20px;" id="divsort">
            <%=strSearchZM %>
        </div>
        <hr style="width: 97%" />
        <div style="overflow: hidden; position: absolute; width: 98%" id="divrole">
            <asp:Repeater ID="RptRole" runat="server">
                <ItemTemplate>
                    <div class="topic-item" serzm="<%#Eval("SerZM") %>" rolename="<%#Eval("RoleName") %>"
                        rolecode="<%#Eval("RoleCode") %>" issys="<%#Eval("isSysRole") %>" isuse="<%#Eval("IsUse") %>"
                        roledec="<%#Eval("RoleDec") %>">
                        <div class="topic-img">
                            <img src="../../images/ic_menu_group.png" style="width: 64px; height: 64px;">
                        </div>
                        <div class="topic-title">
                            <span style="color: #4987C9">
                                <%#DataBinder.Eval(Container.DataItem, "RoleName")%></span>
                        </div>
                    </div>
                </ItemTemplate>
            </asp:Repeater>
        </div>
        <div id="MangerRole" style="display: none">
            <div class="container-fluid">


                <fieldset>
                    <div class="form-group">
                        <label for="tbRoleName">角色名称</label>
                        <asp:TextBox ID="tbRoleName" class="form-control" runat="server" Text="" Width="200px" />
                    </div>
                    <label></label>
                    <div class="form-group">
                        <label for="tbRoleDec">角色描述</label>
                        <asp:TextBox ID="tbRoleDec" runat="server" CssClass="form-control" Text="" Title="角色功能描述,请尽量使用描述性语言。例：最高权限，可以在系统内做任何动作！"
                            Width="388px" />
                    </div>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="ckIsSys">
                            是否为系统角色
                        </label>
                    </div>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="ckIsUse">可用
                        </label>
                    </div>

                </fieldset>

            </div>
        </div>
        <script type="text/javascript" src='../../JqueryPlug/lhgdialog/lhgdialog.js?self=true&skin=idialog'></script>

    </form>
</body>
</html>
